/*
 * @Date: 2024-04-23 15:47:23
 * @LastEditors: 王帅 1677191300@qq.com
 * @LastEditTime: 2024-06-26 17:22:13
 * @FilePath: \pcVue3\vite.config.ts
 * @Description: 
 */
import { defineConfig, loadEnv } from "vite";
import { fileURLToPath, URL } from "node:url";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import VueDevTools from "vite-plugin-vue-devtools";
import legacy from '@vitejs/plugin-legacy'
// https://vitejs.dev/config/
export default defineConfig(({ command, mode }) => {
  const env = loadEnv(mode, process.cwd(), '')
  return {
    plugins: [
      vue(),
      vueJsx(),
      VueDevTools(),
      legacy({
        targets: ["defaults", "not IE 11"],
      })
    ],
    base: "./",
    resolve: {
      alias: {
        "@": fileURLToPath(new URL("./src", import.meta.url)),
      },
      // https://cn.vitejs.dev/config/#resolve-extensions
      extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
    },
    server: {
      // host: "crm-local.vchangyi.com",
      port: 8080,
      host: "0.0.0.0",
      proxy: {
        "/api": {
          target: env.VITE_APP_API_ROOT,
          changeOrigin: true,
          rewrite: (path) => path.replace(/^\/api/, ""),
        },
      },
    },
  }

});
